package main;

import ourfilter.CircularShiftFilter;
import ourfilter.IgnoreWordFilter;
import ourfilter.OurSink;
import ourfilter.SortLinesFilter;
import ourfilter.Source;
import ourfilter.TokenizerFilter;
import pipes.Pipe;
import TransferObjekts.Line;
import TransferObjekts.Word;

public class ConsoleRun {

	public static void main(String[] args) {
		if(args.length != 3){
			throw new IllegalArgumentException("Parameterliste nicht korrekt");
		}
		
		if(args[0].equals("-pull")){
			Pipe<Line> p1 = new Pipe<Line>();
			Pipe<Word> p2 = new Pipe<Word>();
			Pipe<Word> p3 = new Pipe<Word>();
			Pipe<Line> p4 = new Pipe<Line>();
			Pipe<Line> p5 = new Pipe<Line>();

			new Source(args[1], p1);

			new TokenizerFilter(p1, p2);
			new IgnoreWordFilter(p2, p3);
			new CircularShiftFilter(p3, p4);
			new SortLinesFilter(p4, p5);
			OurSink sink = new OurSink(p5, args[2]);

			sink.run();
		}else{

			Pipe<Line> p1 = new Pipe<Line>();
			Pipe<Word> p2 = new Pipe<Word>();
			Pipe<Word> p3 = new Pipe<Word>();
			Pipe<Line> p4 = new Pipe<Line>();
			Pipe<Line> p5 = new Pipe<Line>();

			Source src = new Source(args[1], p1);

			new TokenizerFilter(p1, p2);
			new IgnoreWordFilter(p2, p3);
			new CircularShiftFilter(p3, p4);
			new SortLinesFilter(p4, p5);
			new OurSink(p4, args[2]);
			
			src.run();
		}
	}

}
